﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PocketEngine.Images;
using FastMath;
using PocketEngine.Physics;
using PocketEngine.Engine;
using PocketEngine.Maps;
namespace PocketEngine.Particles
{
    public class pParticle
    {
        public virtual pParticle Clone(pColor col)
        {
            throw new NotImplementedException();
        }
        public pImage Visual = null;
        
        public Vector3 Position;
        public Vector3 Inertia;
        public float Size = 1;
        public float SizeInc = 1;
        public PocketEngine.Engine.pColor Color = Engine.pColor.White;
        public float Drag = 1;
        public float Alpha = 1;
        public float Decline = 0.95f;
        public float Scale = 1;
        public bool CastLight = false;
        
        public pEntity Entity = null;
        public bool Simulated = true;

        public pParticle(pImage img)
        {
            Visual = img;

        }
        public float Rotation = 0;
     
        public pParticle()
        {

        }
        public virtual void Update(Maps.pMap map)
        {
            if (Simulated)
            {
                Position = new Vector3(Entity.Body.Position.X, Entity.Body.Position.Y, 8);
                Rotation = Entity.Body.Rotation;
            }
            else
            {
               Vector3 NewPos = Position + Inertia;
               Position = NewPos;
                Inertia *= Drag;
                if (Position.Z > 0 && Inertia.Z < -6)
                {
                    Inertia.Z += 0.1f;
                }
            }
            Alpha *= Decline;
            Size *= SizeInc;
        }
        public virtual void Draw()
        {
        }
    }
}
